# # -*- coding:utf-8 -*-
# import cv2.cv2 as cv2
#
# pic_path = "./555.jpg"
#
# img = cv2.imread(pic_path)
#
# # Image to Gray Image
# gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#
# # Gray Image to Inverted Gray Image
# inverted_gray_image = 255 - gray_image
#
# # Blurring The Inverted Gray Image
# blurred_inverted_gray_image = cv2.GaussianBlur(inverted_gray_image, (17, 17), 0)
#
# # Inverting the blurred image
# inverted_blurred_image = 255 - blurred_inverted_gray_image
#
# # Preparing Photo sketching
# sketck = cv2.divide(gray_image, inverted_blurred_image, scale=256.0)
#
# # cv2.imshow("Original Image", img)
# # cv2.imshow("Pencil Sketch", sketck)
# write_path = "./551x.jpg"
# cv2.imwrite(write_path, sketck)
# # cv2.waitKey(0)


import cv2
import numpy as np

# Reading the Image
image = cv2.imread("555.jpg")
# Finding the Edges of Image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.medianBlur(gray, 7)
edges = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 10)
# Making a Cartoon of the image
color = cv2.bilateralFilter(image, 12, 250, 250)
cartoon = cv2.bitwise_and(color, color, mask=edges)
# Visualize the cartoon image
# cv2.imshow("Cartoon", cartoon)
write_path = "./552x.jpg"
cv2.imwrite(write_path, cartoon)
cv2.waitKey(0)  # "0" is Used to close the image window
cv2.destroyAllWindows()
